package cn.eng.Department;

import cn.eng.Department.basic.BasicTest;
import cn.eng.org.domain.Department;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.concurrent.TimeUnit;

public class RedisTest01 extends BasicTest {
    @Autowired
    private RedisTemplate redisTemplate;

    /**
     * 测试redis
     * @throws Exception
     */
    @Test
    public void test3() throws Exception {
        redisTemplate.opsForValue().set("name","zhangsan",30, TimeUnit.MINUTES);
        Object name = redisTemplate.opsForValue().get("name");
        System.out.println(name);
    }

    /**
     * 测试redis
     * @throws Exception
     */
    @Test
    public void test4() throws Exception {
        Department department = new Department();
        department.setSn("1");
        department.setName("肖丕才");
        redisTemplate.opsForValue().set("bb",department,30,TimeUnit.MINUTES);
        System.out.println(redisTemplate.opsForValue().get("bb"));
    }
}
